


USE ATS 
Go





SELECT t.name AS [Table Name], i.name AS [Index Name], i.type_desc,
    i.data_space_id, f.name AS [Filegroup Name]
FROM sys.indexes AS i
    JOIN sys.filegroups AS f ON i.data_space_id = f.data_space_id
    JOIN sys.tables as t ON i.object_id = t.object_id
        AND i.object_id = OBJECT_ID(N'PIMTest','U')
GO



IF NOT EXISTS (SELECT name FROM sys.indexes WHERE name = 
            N'PIMTest_PIMRecordTime_Index')
    CREATE 
    --UNIQUE 
    CLUSTERED INDEX
        PIMTest_PIMRecordTime_Index 
    ON PIMTest(PIMRecordTime)
    ON 'PRIMARY';
GO

--
USE ATS
GO
IF EXISTS (SELECT name FROM sys.indexes
            WHERE name = N'PIMTest_SN_index')
    DROP INDEX PIMTest_SN_index ON TTest;
GO
CREATE NONCLUSTERED INDEX PIMTest_SN_index
    ON PIMTest(ProductSN);
GO



--
IF NOT EXISTS (SELECT name FROM sys.indexes WHERE name = 
            N'PIMTestItem_PIMRecordTime_Index')
    CREATE 
    --UNIQUE 
    CLUSTERED INDEX
        PIMTestItem_PIMRecordTime_Index 
    ON PIMTestItem(PIMRecordTime)
    ON 'PRIMARY';
GO




select top 10 * from PIMTest 
select top 10 * from PIMTestItem 



































